Merge branch 'master' of git://repo.or.cz/mqlkit
[mqlkit.git] / indicators / ema of lag.mq4
blob3427e4b185f20feea9e2ec816fd47b2743954e33
1 //+------------------------------------------------------------------+\r
2 //|                                                    ma of cci.mq4 |\r
3 //|                      Copyright © 2009, MetaQuotes Software Corp. |\r
4 //|                                        http://www.metaquotes.net |\r
5 //+------------------------------------------------------------------+\r
6 #property indicator_separate_window\r
7 #property indicator_buffers 2\r
8 #property indicator_color1 Red\r
9 #property indicator_color2 Lime\r
10 #property indicator_level1 -150000\r
11 #property indicator_level2 150000\r
12  \r
13 //---- input parameters\r
14 extern double lag_p =0.70;\r
15 extern int MA_Period=13;\r
16 extern int MA_Shift=0;\r
17 extern int MA_Method=0;\r
18 extern int NumberOfBarsToCalculate = 10000;\r
19  \r
20 //---- indicator buffers\r
21 double Buffer0[];\r
22 double Buffer1[];\r
23 double Ma[];\r
24 double Lag[];\r
25  \r
26 //+------------------------------------------------------------------+\r
27 //| Custom indicator initialization function                         |\r
28 //+------------------------------------------------------------------+\r
29   int init()\r
30   {\r
31    Comment("");\r
32    IndicatorBuffers(4);\r
33 //---- indicator line\r
34    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);\r
35    SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);\r
36    SetIndexStyle(2,DRAW_NONE);\r
37    SetIndexStyle(3,DRAW_NONE);\r
38  \r
39    SetIndexBuffer(0,Buffer0);\r
40    SetIndexBuffer(1,Buffer1);\r
41    SetIndexBuffer(2,Ma);\r
42    SetIndexBuffer(3,Lag);\r
43    \r
44  \r
45    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));\r
46 //----\r
47  \r
48    SetIndexEmptyValue(0,0);\r
49    SetIndexEmptyValue(1,0);\r
50    SetIndexEmptyValue(2,0);\r
51    SetIndexEmptyValue(3,0);\r
52 //----\r
53    return(0);\r
54   }\r
55  \r
56  \r
57 int start() {\r
58       string short_name;\r
59       short_name = "Laguerre["+lag_p+"] \ MA => Max bars to count: |"+(Bars-1)+"| ";\r
60       IndicatorShortName(short_name);\r
61  \r
62       int shift;\r
63       double lag = 0;\r
64       for(shift=NumberOfBarsToCalculate-1;shift>=0;shift--){\r
65          Lag[shift] = iCustom(NULL,0,"Laguerre RSI",lag_p,PRICE_CLOSE,shift);    \r
66          }\r
67       for(shift=NumberOfBarsToCalculate-1;shift>=0;shift--){\r
68          Ma[shift] = iMAOnArray(Lag,0,MA_Period,MA_Shift,MA_Method,shift);\r
69          Buffer0[shift] = Lag[shift];\r
70          Buffer1[shift] = Ma[shift];\r
71          }\r
73       return(0);\r